<template>
  <t-dialog :header="`${header}-人员详情`" :visible.sync="visible" :onClose="closeDialog" :closeOnOverlayClick="false"
    :confirmBtn="null" width="80%" top="5%">
    <div style="height: 65vh">
      <t-divider style="font-size: 20px">基本信息</t-divider>
      <t-form ref="form" class="step-form table-form" :data="formData" labelWidth="0px">
        <t-row>
          <t-col :span="2" class="title">姓名：</t-col>
          <t-col :span="4">
            {{ formData.name }}
          </t-col>
          <t-col :span="2" class="title">性别：</t-col>
          <t-col :span="4">
            {{ formData.sex | filterByDict(dict.type.sys_user_sex) }}
          </t-col>
        </t-row>
        <t-row>
          <t-col :span="2" class="title">民族：</t-col>
          <t-col :span="4">
            {{ formData.national | filterByDict(dict.type.national) }}
          </t-col>
          <t-col :span="2" class="title">政治面貌：</t-col>
          <t-col :span="4">
            {{ formData.politicsStatus | filterByDict(dict.type.politics_status) }}
          </t-col>
        </t-row>
        <t-row>
          <t-col :span="2" class="title">所在单位：</t-col>
          <t-col :span="4">
            {{ formData.company }}
          </t-col>
          <t-col :span="2" class="title">通讯地址：</t-col>
          <t-col :span="4">
            {{ formData.address }}
          </t-col>
        </t-row>
        <t-row>
          <t-col :span="2" class="title">手机号：</t-col>
          <t-col :span="4">
            {{ formData.phone }}
          </t-col>
          <t-col :span="2" class="title">邮箱：</t-col>
          <t-col :span="4">
            {{ formData.email }}
          </t-col>
        </t-row>
        <t-row>
          <!--          <t-col :span="2" class="title">学校：</t-col>-->
          <!--          <t-col :span="4">-->
          <!--          </t-col>-->
          <t-col :span="2" class="title">所学专业：</t-col>
          <t-col :span="4">
            {{ formData.majorName }}
          </t-col>
          <t-col :span="2" class="title">现从事专业：</t-col>
          <t-col :span="4">
            {{ formData.majorNowName }}
          </t-col>
        </t-row>
        <t-row>
          <t-col :span="2" class="title">学历：</t-col>
          <t-col :span="4">
            {{ formData.education | filterByDict(dict.type.education) }}
          </t-col>
          <t-col :span="2" class="title">邮编：</t-col>
          <t-col :span="4">
            {{ formData.postCode }}
          </t-col>
          <!--          <t-col :span="2" class="title">学位：</t-col>-->
          <!--          <t-col :span="4">-->
          <!--          </t-col>-->
        </t-row>
        <!--        <t-row>-->
        <!--&lt;!&ndash;          <t-col :span="2" class="title">邮编：</t-col>&ndash;&gt;-->
        <!--&lt;!&ndash;          <t-col :span="4">&ndash;&gt;-->
        <!--&lt;!&ndash;            {{ formData.postCode }}&ndash;&gt;-->
        <!--&lt;!&ndash;          </t-col>&ndash;&gt;-->
        <!--&lt;!&ndash;          <t-col :span="2" class="title">微信号：</t-col>&ndash;&gt;-->
        <!--&lt;!&ndash;          <t-col :span="4">&ndash;&gt;-->
        <!--&lt;!&ndash;          </t-col>&ndash;&gt;-->
        <!--        </t-row>-->
        <t-row>
          <t-col :span="2" class="title">技术职称：</t-col>
          <t-col :span="4">
            {{ formData.profTitId | filterByTree(profTitOptions, children = "children", id = "id", label = "name") }}
          </t-col>
          <t-col :span="2" class="title">职称：</t-col>
          <t-col :span="4">
            {{ formData.profTit | filterByDict(dict.type.prof_tit) }}
          </t-col>
        </t-row>
        <t-row>
          <t-col :span="2" class="title">职务：</t-col>
          <t-col :span="10">
            {{ formData.duty }}
          </t-col>
          <!--          <t-col :span="2" class="title">个人简介：</t-col>-->
          <!--          <t-col :span="4">-->
          <!--          </t-col>-->
        </t-row>
      </t-form>
      <!--      <t-divider style="font-size: 20px">承担项目</t-divider>-->
      <!--      &lt;!&ndash;     <t-table rowKey="id" size="small" :data="data" :columns="columns" hover :pagination="pagination"&ndash;&gt;-->
      <!--      &lt;!&ndash;              :loading="dataLoading">&ndash;&gt;-->
      <!--      &lt;!&ndash;     </t-table>&ndash;&gt;-->
      <t-divider style="font-size: 20px">参与项目</t-divider>
      <t-tabs v-model="tabValue">
        <t-tab-panel v-for="(tab, tabIndex) in tabList" :key="tabIndex" :value="tab.value">
          <template #label>
            {{ tab.label }}
            <t-badge style="position: relative" :count="tab.count" show-zero :offset="[-6, 0]"></t-badge>
          </template>
          <div v-if="tab.value === '0'">
            <kjxm-list :idCard="objId"></kjxm-list>
          </div>
          <div v-if="tab.value === '1'">
            <bzh-list :idCard="objId"></bzh-list>
          </div>
          <div v-if="tab.value === '2'">
            <kjsf-list :idCard="objId"></kjsf-list>
          </div>
          <div v-if="tab.value === '3'">
            <wcx-list :idCard="objId"></wcx-list>
          </div>
        </t-tab-panel>
      </t-tabs>
      <t-divider style="font-size: 20px">研究成果</t-divider>
      <t-tabs v-model="tabValue2">
        <t-tab-panel v-for="(tab, tabIndex) in resultTabList" :key="tabIndex" :value="tab.value">
          <template #label>
            {{ tab.label }}
            <t-badge style="position: relative" :count="tab.count" show-zero :offset="[-6, 0]"></t-badge>
          </template>
          <div v-if="tab.value === '0'">
            <thesis-list :idCard="objId"></thesis-list>
          </div>
          <div v-if="tab.value === '1'">
            <treatise-list :idCard="objId"></treatise-list>
          </div>
          <div v-if="tab.value === '2'">
            <patent-list :idCard="objId"></patent-list>
          </div>
          <div v-if="tab.value === '3'">
            <copyright-list :idCard="objId"></copyright-list>
          </div>
          <div v-if="tab.value === '4'">
            <awards-list :idCard="objId"></awards-list>
          </div>
          <div v-if="tab.value === '7'">
            <gf-list :idCard="objId"></gf-list>
          </div>
          <div v-if="tab.value === '8'">
            <other-list :idCard="objId"></other-list>
          </div>
        </t-tab-panel>
      </t-tabs>

    </div>
  </t-dialog>
</template>

<script>
import kjxmList from "@/pages/common/system/components/kjxm-list.vue";
import bzhList from "@/pages/common/system/components/bzh-list.vue";
import kjsfList from "@/pages/common/system/components/kjsf-list.vue";
import wcxList from "@/pages/common/system/components/wcx-list.vue";
import thesisList from "@/pages/common/system/components/thesis-list.vue";
import TreatiseList from "@/pages/common/system/components/treatise-list.vue";
import patentList from "@/pages/common/system/components/patent-list.vue";
import CopyrightList from "@/pages/common/system/components/copyright-list.vue";
import AwardsList from "@/pages/common/system/components/awards-list.vue";
import GfList from "@/pages/common/system/components/gf-list.vue";
import OtherList from "@/pages/common/system/components/other-list.vue";

export default {
  name: "user-all-detail",
  props: ["objId", "expertId", "header"],
  dicts: ['prof_tit', 'duty', "degree", "sys_user_sex", "national", "politics_status", "education", "politics_status"],
  components: {
    OtherList,
    GfList,
    AwardsList,
    CopyrightList,
    TreatiseList,
    kjxmList,
    bzhList,
    kjsfList,
    wcxList,
    thesisList,
    patentList
  },
  data () {
    return {
      site_tag: import.meta.env.VITE_SITE_TAG,
      visible: true,
      tabValue: '0',
      tabValue2: '0',
      profTitOptions: [],
      deptMenuOptions: [],
      formData: {
        companyId: null,
        politicsStatus: '',
        national: '',
        degree: '',
        school: '',
        postCode: '',
        email: '',
        address: '',
        phone: '',
        name: '',
        sex: '',
        birthDate: '',
        duty: '',
        profTit: '',
        profTitId: null,
        majorName: '',
        majorNowName: '',
        company: '',
        task: '',
        education: '',
        idCard: '',
        isAssist: '0',
        isInnerCompany: '1',
      },
      tabList: [
        { label: '科技项目', value: '0', count: 0 },
        { label: '标准化', value: '1', count: 0 },
        { label: '示范工程', value: '2', count: 0 },
      ],
      resultTabList: [
        { label: '论文', value: '0', count: 0 },
        { label: '著作', value: '1', count: 0 },
        { label: '专利', value: '2', count: 0 },
        { label: '软件著作权', value: '3', count: 0 },
        { label: '获奖', value: '4', count: 0 },
        // {label: '标准', value: '5', count: 0},
        // {label: '人才', value: '6', count: 0},
        // {label: '微创新', value: '6', count: 0},
        { label: '工法', value: '7', count: 0 },
        { label: '其他', value: '8', count: 0 },
      ],
      queryParams2: {},
      data2: [],
      columns2: [],
      pagination2: {
        current: 1,
        pageSize: 10,
        total: 0,
        showPageSize: true,
        pageSizeOptions: [10, 20, 30, 50],
        showFirstAndLastPageBtn: false,
        onChange: (pageInfo) => {
          Object.assign(this.pagination, pageInfo)
          this.queryParams2.pageNum = pageInfo.current || 1;
          this.queryParams2.pageSize = pageInfo.pageSize;
          this.getProjectList()
        },
      },
    }
  },
  created () {
    if (this.objId) {
      this.getKjxmList();
      this.getBzhList();
      this.getKjsfList();
      if (this.site_tag === 'jt') {
        this.tabList.push({ label: '微创新', value: '3', count: 0 })
        this.getWcxList();
      }
      this.getThesisList();
      this.getTreatiseList();
      this.getPatentList();
      this.getCopyrightList();
      this.getGfList();
      this.getOtherList();
      this.getAwardsList();
      this.getProfTitTreeSelect();

      this.getObj();
    }

  },
  methods: {
    getThesisList () {
      this.$api.cgzh.thesis.getJoinList({
        pageNum: 1,
        pageSize: 10,
        idCard: this.objId
      }).then(response => {
        const index = this.resultTabList.findIndex((val) => val.value === '0')
        this.$set(this.resultTabList[index], 'count', response.total)
      }).catch((e) => {
        this.dataLoading = false;
        this.$message.error(e.toString());
      });
    },
    getTreatiseList () {
      this.$api.cgzh.treatise.getJoinList({
        pageNum: 1,
        pageSize: 10,
        idCard: this.objId
      }).then(response => {
        const index = this.resultTabList.findIndex((val) => val.value === '1')
        this.$set(this.resultTabList[index], 'count', response.total)
      }).catch((e) => {
        this.dataLoading = false;
        this.$message.error(e.toString());
      });
    },
    getPatentList () {
      this.$api.cgzh.patent.getJoinList({
        pageNum: 1,
        pageSize: 10,
        idCard: this.objId
      }).then(response => {
        const index = this.resultTabList.findIndex((val) => val.value === '2')
        this.$set(this.resultTabList[index], 'count', response.total)
      }).catch((e) => {
        this.dataLoading = false;
        this.$message.error(e.toString());
      });
    },
    getCopyrightList () {
      this.$api.cgzh.copyright.getJoinList({
        pageNum: 1,
        pageSize: 10,
        idCard: this.objId
      }).then(response => {
        const index = this.resultTabList.findIndex((val) => val.value === '3')
        this.$set(this.resultTabList[index], 'count', response.total)
      }).catch((e) => {
        this.dataLoading = false;
        this.$message.error(e.toString());
      });
    },
    getAwardsList () {
      this.$api.cgzh.awards.getJoinList({
        pageNum: 1,
        pageSize: 10,
        idCard: this.objId
      }).then(response => {
        const index = this.resultTabList.findIndex((val) => val.value === '4')
        this.$set(this.resultTabList[index], 'count', response.total)
      }).catch((e) => {
        this.dataLoading = false;
        this.$message.error(e.toString());
      });
    },
    getGfList () {
      this.$api.cgzh.gf.getJoinList({
        pageNum: 1,
        pageSize: 10,
        idCard: this.objId
      }).then(response => {
        const index = this.resultTabList.findIndex((val) => val.value === '7')
        this.$set(this.resultTabList[index], 'count', response.total)
      }).catch((e) => {
        this.dataLoading = false;
        this.$message.error(e.toString());
      });
    },
    getOtherList () {
      this.$api.cgzh.other.getJoinList({
        pageNum: 1,
        pageSize: 10,
        idCard: this.objId
      }).then(response => {
        const index = this.resultTabList.findIndex((val) => val.value === '8')
        this.$set(this.resultTabList[index], 'count', response.total)
      }).catch((e) => {
        this.dataLoading = false;
        this.$message.error(e.toString());
      });
    },

    getKjxmList () {
      this.$api.kjxm.project.myJoinList({
        pageNum: 1,
        pageSize: 10,
        idCard: this.objId
      }).then(response => {
        this.$set(this.tabList[0], 'count', response.total)
      }).catch((e) => {
        this.dataLoading = false;
        this.$message.error(e.toString());
      });
    },
    getBzhList () {
      this.$api.bzh.standard.myJoinList({
        pageNum: 1,
        pageSize: 10,
        idCard: this.objId
      }).then(response => {
        this.$set(this.tabList[1], 'count', response.total)
      }).catch(e => {
        this.dataLoading = false
        this.$message.error(e.toString())
      })
    },
    getKjsfList () {
      this.$api.kjsf.project.myJoinList({
        pageNum: 1,
        pageSize: 10,
        idCard: this.objId
      }).then(response => {
        this.$set(this.tabList[2], 'count', response.total)
      }).catch(e => {
        this.dataLoading = false
        this.$message.error(e.toString())
      })
    },
    getWcxList () {
      this.$api.wcx.innovation.myJoinList({
        pageNum: 1,
        pageSize: 10,
        idCard: this.objId
      }).then(
        (response) => {
          this.$set(this.tabList[3], 'count', response.total)
        }).catch((e) => {
          this.dataLoading = false;
          this.$message.error(e.toString());
        });
    },
    closeDialog () {
      this.$emit("update:visible", false);
    },
    getProfTitTreeSelect () {
      return this.$api.system.profTit.list().then(response => {
        this.profTitOptions = this.handleTree(response.data, "id");
      }).catch((e) => {
        this.$message.error(e.toString());
      });
    },
    getObj () {
      this.$api.system.member.getByIdCard(this.objId).then(response => {
        this.formData = response.data;
      }).catch((e) => {
        this.$message.error(e.toString());
      });
    }
  }
}
</script>

<style lang="less" scoped>
.t-tab-panel {
  padding: 10px;
}

/deep/ .t-badge--circle {
  position: relative;
}

.step-card {
  height: 100%;
  margin-bottom: 14px;
}

.table-form {
  /deep/ .t-radio.t-is-disabled .t-radio__label {
    color: unset
  }

  /deep/ .t-checkbox.t-is-disabled .t-checkbox__label {
    color: unset
  }

  /deep/ .t-radio.t-is-disabled .t-radio__input {
    background-color: unset;
  }

  /deep/ .t-is-error .t-input__extra {
    position: static;
  }

  /deep/ .t-form__label {
    display: none;
  }

  .t-form__item {
    width: 100%;
  }

  .t-row {
    align-items: stretch;
    margin-bottom: 0;

    .require {
      color: red;
      margin-right: 3px;
    }

    .t-col {
      border: 1px solid #ddd;
      color: #333;
      min-height: 37px;
      padding: 4px !important;
      //overflow: hidden;
      display: flex;
      align-items: center;
      margin: 0px -1px -1px 0px;

      .t-row {
        width: 100%;
      }
    }

    .title {
      background-color: #FAFAFA;
      justify-content: center;
      margin: 0px -1px -1px 0px;
      color: #000000;
      font-size: 16px;
      font-family: '宋体', serif;
      font-weight: bold;
    }
  }
}
</style>
